<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
 ! Excerpted from "Mastering Dojo",
 ! published by The Pragmatic Bookshelf.
 ! Copyrights apply to this code. It may not be used to create training material, 
 ! courses, books, articles, and the like. Contact us if you are in doubt.
 ! We make no guarantees that this code is fit for any purpose. 
 ! Visit http://www.pragmaticprogrammer.com/titles/rgdojo for more book information.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tree OnClick</title>
    <style type="text/css">
        @import "/dojoroot/dijit/themes/tundra/tundra.css";
    </style>
    <script type="text/javascript" src="/dojoroot/dojo/dojo.js"  djConfig="parseOnLoad: true,isDebug:true"></script>
    <script type="text/javascript">
       dojo.require("dojo.parser");
       dojo.require("dojo.data.ItemFileReadStore");
       dojo.require("dijit.Tree");

       var lastBoxSelected = null;
       
     </script>
</head>
<body class="tundra">
   <!--  The SplitContainer puts a movable divider between the ContentPanes -->
   <script>
       dojo.require("dojo.data.ItemFileWriteStore");
       dojo.require("dijit.layout.BorderContainer");
       dojo.require("dijit.layout.ContentPane");
   </script>


   <div dojoType="dijit.layout.BorderContainer" style="width:600px; height:400px"
   >
       <div dojoType="dijit.layout.ContentPane" region="leading">
       Box Tree
       </div>
       
       <div dojoType="dijit.layout.ContentPane" region="trailing">
       Order Tree
       </div>
   </div>
-->
          
   <div dojoType="dijit.layout.BorderContainer" style="width:600px; height:400px"
        design="headline"  liveSizing="true">
        
        <!-- The left hand tree has nothing new except (1) ItemFileWriteStore
             (2) the onClick extension handler in the tree -->

        <div dojoType="dijit.layout.ContentPane" region="leading"
             splitter="true" style="width:200px"
        >
           <div dojoType="dojo.data.ItemFileWriteStore" 
                url="datasources/rma_boxes.json"         
                jsId="boxJson"></div>
                
           <div dojoType="dijit.tree.ForestStoreModel" store="boxJson"
                jsId="boxModel" rootLabel="Boxes"></div> 
                
           <div dojoType="dijit.Tree" id="boxes" model="boxModel">
                <script type="dojo/method" event="onClick" args="item">
                   // Given item, the backing dojo.data.Item backing this node,
                   // save it for later deleting and/or renaming
                   lastBoxSelected = item;
                </script>
           </div>
        </div>


        <!--  This is the order/line/serial tree, wrapped in a ContentPane -->
        <div dojoType="dijit.layout.ContentPane" region="center">
           <div dojoType="dojo.data.ItemFileReadStore" 
                url="datasources/order_with_serial.json"         
                jsId="ordJson"></div>

           <div dojoType="dijit.tree.ForestStoreModel" store="ordJson"
                jsId="ordModel" rootLabel="Order"
                childrenAttrs="line,serial"
                ></div> 
    
           <div dojoType="dijit.Tree" id="ordTree" 
                model="ordModel" ></div>
       </div>
   </div>
</body></html>        